package ai.peanut.selfbase.common.exception;

import ai.peanut.selfbase.common.domain.ErrorCode;

public class SystemException extends RuntimeException {
	private static final long serialVersionUID = -8995909169223941100L;
	/**
	 * 错误码
	 */
	private int errorCode;
	/**
	 * 移动端返回码
	 */
	private String resultCode;
	/**
	 * 错误描述
	 */
	private String errorReason;

	public SystemException(int errorCode, String resultCode, String errorReason) {
		this.errorCode = errorCode;
		this.resultCode = resultCode;
		this.errorReason = errorReason;
	}

	public SystemException(int errorCode, String errorReason) {
		this.errorCode = errorCode;
		this.errorReason = errorReason;
	}

	public SystemException(ErrorCode errorCode) {
		this(errorCode.getErrorCode(), errorCode.getResultCode(),errorCode.getErrorReason());
	}

	public int getErrorCode() {
		return errorCode;
	}

	public String getResultCode(){return resultCode;}

	public String getErrorReason() {
		return errorReason;
	}

	public SystemException setCause(Throwable t) {
		super.initCause(t);
		return this;
	}
}
